package com.neusoft.neuhealth.controller;

import com.neusoft.neuhealth.domain.SetMeal;
import com.neusoft.neuhealth.po.ListResult;
import com.neusoft.neuhealth.po.Result;
import com.neusoft.neuhealth.po.diet.params.*;
import com.neusoft.neuhealth.po.diet.result.*;
import com.neusoft.neuhealth.service.IDietService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Tag(name = "膳食管理接口")
@RestController
@RequestMapping("/diet")
public class DietController {
    @Autowired
    private IDietService dietService;

    @Operation(summary = "获取某个月内每天的套餐配置信息")
    @GetMapping("/monthList")
    public Result<List<DietCalendarResult>> monthList(DietCalendarMonthListParams params){
        return dietService.monthList(params);
    }

    @Operation(summary = "保存某天的套餐配置信息")
    @PostMapping("/saveDietCalendar")
    public Result saveDietCalendar(@RequestBody DietCalendarSaveParams params){
        return dietService.saveDietCalendar(params);
    }

    @Operation(summary = "获取套餐信息列表")
    @GetMapping("/setMeal/list")
    public Result<ListResult<SetMealResult>> setMealList(String status, String pork, String setMealName, Integer pageNum, Integer pageSize){
        return dietService.getSetMealList(status, pork, setMealName, pageNum, pageSize);
    }

    @Operation(summary = "获取某一天的套餐信息列表")
    @GetMapping("/setMeal/dailyList")
    public Result<List<SetMeal>> dailyList(String date){
        return dietService.getDailyList(date);
    }

    @Operation(summary = "修改套餐信息")
    @PostMapping("/setMeal/update")
    public Result updateSetMeal(@RequestBody SetMeal setMeal){
        return dietService.updateSetMeal(setMeal);
    }

    @Operation(summary = "删除套餐")
    @PostMapping("/setMeal/remove")
    public Result removeSetMeal(@RequestBody Long setMealId){
        return dietService.removeSetMeal(setMealId);
    }

    @Operation(summary = "获取某个时间段的可选菜品列表")
    @GetMapping("/timeFoodOptions")
    public Result<List<DishResult>> timeDishOptions(String time, String pork){
        return dietService.timeDishOptions(time, pork);
    }

    @Operation(summary = "获取菜品信息列表")
    @GetMapping("/foodList")
    public Result<DishListResult> dishList(DishListParams params){
        return dietService.dishList(params);
    }

    @Operation(summary = "添加菜品")
    @PostMapping("/addFood")
    public Result addDish(@RequestBody DishParams params){
        return dietService.addDish(params);
    }

    @Operation(summary = "修改菜品")
    @PutMapping("/updateFood")
    public Result updateDish(@RequestBody DishParams params){
        return dietService.updateDish(params);
    }

    @Operation(summary = "删除菜品")
    @PostMapping("/deleteFood")
    public Result removeDish(@RequestBody RemoveDishParams params){
        return dietService.removeDish(params);
    }

    @Operation(summary = "获取客户菜品列表")
    @GetMapping("/customerList")
    public Result<ListResult<CustomerDishListResult>> customerList(CustomerListParams params){
        return dietService.customerList(params);
    }

    @Operation(summary = "保存客户套餐配置")
    @PostMapping("/saveCustomerSetMeal")
    public Result saveCustomerSetMeal(@RequestBody SaveCustomerSetMealParams params){
        return dietService.saveCustomerSetMeal(params);
    }

    @Operation(summary = "获取可用的菜品列表")
    @GetMapping("/availableDishes")
    public Result<List<DishResult>> availableDishes(String time,String pork){
        return dietService.availableDishes(time,pork);
    }

    @Operation(summary = "保存套餐菜品配置")
    @PostMapping("/saveSetMealDishes")
    public Result saveSetMealDishes(@RequestBody SaveSetMealDishesParams params){
        return dietService.saveSetMealDishes(params);
    }

    @Operation(summary = "上传菜品图片")
    @PostMapping("/img/upload")
    public Result uploadImg(@RequestParam(name ="file", required = false) MultipartFile file,@RequestParam("name") String name){
        if(file != null)
            return dietService.uploadImg(file,name);
        Result result = new Result();
        result.setCode(200);
        return result;
    }
}
